package com.magenta.maxoptra.gis;

import static com.magenta.maxoptra.gis.GISFieldType.TEXT;
import static com.magenta.maxoptra.gis.MapProviderType.geoinformsputnik;

/**
 * User: KuznetsovD
 * Date: 25.10.11
 * Time: 16:14
 */
public enum GeoInformSputnikMapAttribute implements GISAccountProperty {
    UseProvider(GisParameter.use_map_provider, MapProviderType.geoinformsputnik, GISFieldType.BOOLEAN, "false", true, 0L, true),
    GeoInformSputnikUrl(GisParameter.geocoding_url, geoinformsputnik, TEXT, "http://geoportal.samregion.ru/wfs12", false, 1L, true),
    GeoInformSputnikSearchLayer(GisParameter.layers, geoinformsputnik, TEXT, "EC_1_10", false, 2L, true),
    GeoInformSputnikEnableCache(GisParameter.enableCache, geoinformsputnik, GISFieldType.BOOLEAN, "true", true, 3L, true),
    GeoInformSputnikProjection(GisParameter.projection, geoinformsputnik, TEXT, "SamObl_Transformed", true, 4L, true),
    GetGeoInformSputnikCustomMapConfig(GisParameter.custom_map_config, MapProviderType.geoinformsputnik, TEXT, "{\n" +
            "  \"url\":\"http://geoportal.samregion.ru/wms13\",\n" +
            "  \"layers\": \"E3,E2,E1\",\n" +
            "  \"projection\": {\n" +
            "      \"code\": \"EPSG:4326\",\n" +
            "      \"defs\": \"+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=9601000 +y_0=101000 +ellps=krass +towgs84=23.9,-141.3,-80.9,0,0.35,0.86,0.12 +units=m +no_defs\",\n" +
            "      \"opts\": {}\n" +
            "  }\n" +
            "}", true, 5L, true);

    private String name;
    private String label;
    private String tab = "GIS";
    private Long order;
    private GISFieldType type;
    private String defaultValue;
    private boolean required;
    private String groupName;
    private boolean important = true;

    public boolean isImportant() {
        return important;
    }

    public String getName() {
        return name;
    }

    public GISFieldType getType() {
        return type;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public Boolean getMandatory() {
        return required;
    }

    public String getGroup() {
        return groupName;
    }

    public String getLabel() {
        return label;
    }

    public Long getOrder() {
        return order;
    }

    public String getTab() {
        return tab;
    }

    private GeoInformSputnikMapAttribute(String name, String label, GISFieldType type, String defaultValue,
                                         boolean required, String groupName, Long order, boolean important) {
        this.name = name;
        this.label = label;
        this.type = type;
        this.defaultValue = defaultValue;
        this.groupName = groupName;
        this.required = required;
        this.order = order;
        this.important = important;
    }

    private GeoInformSputnikMapAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                                         String defaultValue, boolean required, Long order, boolean important) {
        this(parameter.withProvider(providerType.name()),
                parameter.getLabel(),
                type,
                defaultValue,
                required,
                providerType.getLabel(),
                order, important);
    }

    public boolean isReadOnly() {
        return false;
    }

}
